package com.ecommerce.dal.common;

import java.util.Date;
import java.util.List;

import com.ecommerce.dal.entity.Customer;
import com.ecommerce.dal.service.impl.CustomerManagerService;



public class TestInheritedCustomer {

	public TestInheritedCustomer(CustomerManagerService customerManagerService) {
		// User user = new User();
		// user.setUserId(1L);
		Customer customer = new Customer();
		// Increment
		long id = 29;
		customer.setFirstName("etch" + id);
		customer.setUserName("customer" + id);
		customer.setPassword("123");
		customer.setLastName("etch" + id);
		customer.setNewsletter(true);
		customer.setBirthDate(new Date());
		customer.setGender("male");
		customer.setJoinDate(new Date());
		customer.setVerified(true);
		customerManagerService.saveCustomer(customer);

	
		/** verified **/
		System.out.println("-------------- verified ---------------");
		List<Customer> vCustomerList = customerManagerService
				.retrieveVerifiedCustomers();
		for (Customer customerX : vCustomerList) {
			System.out.println("Customer Id: " + customerX.getUserId()
					+ " , Customer Name: " + customerX.getFirstName() + " "
					+ customerX.getLastName() + " , Verified? "
					+ ((customerX.isVerified() == true) ? "Yes" : "No"));
		}
		System.out.println("--------------------------");

		/** verified **/
		System.out.println("-------------- Not verified ---------------");
		List<Customer> nvCustomerList = customerManagerService
				.retrieveNonVerifiedCustomers();
		for (Customer customerX : nvCustomerList) {
			System.out.println("Customer Id: " + customerX.getUserId()
					+ " , Customer Name: " + customerX.getFirstName() + " "
					+ customerX.getLastName() + " , Verified? "
					+ ((customerX.isVerified() == true) ? "Yes" : "No"));
		}
		System.out.println("--------------------------");

		/** is verified ? **/
		System.out.println("-------------- is verified ?---------------");
		boolean checkCustomer = customerManagerService.isVerifiedCustomer(id);
		System.out.println("Customer number "+ id +" is " + ((checkCustomer== true) ? "" : "not ") + "verified");
		System.out.println("--------------------------");
		
		/** select **/
		
		Customer customer2 = customerManagerService.retrieveCustomer(25L);
		System.out.println("Selecting customer2: \n");
		System.out.println(customer2);
		System.out.println("Customer number 37 does exists ? "
				+ customerManagerService.checkIfClient(37L));
		System.out.println("Is there a client number 37 ? "
				+ customerManagerService.checkIfClient(37L));
		/** update **/
		customer2.setFirstName("ahmed");
		customerManagerService.updateCustomer(customer2);
	}

}
